const fs = require("fs");
const csvParser = require("csv-parser");
const http = require("http");

const results = [];
fs.createReadStream("./resultcsv-fanhua.csv")
  .pipe(csvParser())
  .on("data", (row) => {
    results.push(row);
  })
  .on("end", () => {
    results.forEach((item, index) => {
      const req = http.request("http://localhost:3000/api/validation", {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
        },
      });
      const name = `exp${index + 1}`;
      const group = `test${index + 1}`;

      req.write(
        JSON.stringify({
          name,
          group,
          virtual: "true",
          noise: 0,
          indicator1: item["mAP_0.5"],
          indicator2: item["mAP_50_95"],
        })
      );
      req.end();
    });
  });
